/*
 * jpTrataParametros.java
 *
 * Created on 24 de julio de 2008, 09:58 AM
 */

package Mantenimiento;
import utiles.*;
import java.util.ArrayList;
import java.rmi.*;
import pantalla.*;
/**
 *
 * @author  Administrador
 */
public class jpTrataParametros extends javax.swing.JPanel {
    String identificador;
    funcioncliente.FuncionesControlAcceso fca;
    javax.swing.JInternalFrame jif;
    /** Creates new form jpTrataParametros */
    public jpTrataParametros(String cone[],String id) {
        identificador=id;
        initComponents();
        if (System.getSecurityManager() == null){
 		System.setSecurityManager(new RMISecurityManager());
 		}
        
        try{
			fca=(funcioncliente.FuncionesControlAcceso)java.rmi.Naming.lookup("//"+cone[0]+":"+cone[1]+"/"+cone[2]);
                       
                        }catch(Exception g){
				utiles.Utiles_MensajesDialogo.mensajeError("Problemas conectando "+g.toString());
                                g.printStackTrace();
                            
		}
        refrescar();
        
        ////////////////////////////
        redimensionar();
        jtCuentas.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    }
    
    public  void ponerancestro(javax.swing.JInternalFrame jjj){
        jif=jjj;
    }
    void redimensionar(){
        javax.swing.table.TableColumn columna=jtCuentas.getColumnModel().getColumn(0);
        columna.setPreferredWidth(40);
        columna=jtCuentas.getColumnModel().getColumn(1);
        columna.setPreferredWidth(400);
        columna=jtCuentas.getColumnModel().getColumn(2);
        columna.setPreferredWidth(35);
        columna=jtCuentas.getColumnModel().getColumn(3);
        columna.setPreferredWidth(20);
        columna=jtCuentas.getColumnModel().getColumn(4);
        columna.setPreferredWidth(12);
        columna=jtCuentas.getColumnModel().getColumn(5);
        columna.setPreferredWidth(60);
        columna=jtCuentas.getColumnModel().getColumn(6);
        columna.setPreferredWidth(40);
        columna=jtCuentas.getColumnModel().getColumn(7);
        columna.setPreferredWidth(50);
        columna=jtCuentas.getColumnModel().getColumn(8);
        columna.setPreferredWidth(40);
        columna=jtCuentas.getColumnModel().getColumn(9);
        columna.setPreferredWidth(12);
        columna=jtCuentas.getColumnModel().getColumn(10);
        columna.setPreferredWidth(100);
        
    }
    
    public   void cerrar(){
          int res = javax.swing.JOptionPane.showConfirmDialog( this,"Esta seguro de salir?",
      "Confirmar",javax.swing.JOptionPane.YES_NO_OPTION );
         if(res==javax.swing.JOptionPane.YES_OPTION){
                   jif.dispose();
                  
         }
      }
    void refrescar(){
        jtCuentas.setModel(ConsultasCliRmi.llenatabla("SELECT id_parametro as ID,descripcion," +
                " param1 as P1, param2 as P2,param3 as P3, param4 as P4,param5 as P5," +
                " param7 as P7, param8 as P8, param9 as P9,param10 as P10,fecha, " +
                " paramEntero " +
                " FROM parametros " +
                " where id_parametro not like 'AC%' " +
                " and id_parametro not like 'CG%' " +
                " and id_parametro not like 'CO%' " +
                " and id_parametro not like 'PR%' " +
                " and id_parametro not like 'SU%'  " +
                " and id_parametro not like 'TE%'",identificador));
        redimensionar();
        
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jtCuentas = new javax.swing.JTable();
        jbModificar = new javax.swing.JButton();
        jbSalir = new javax.swing.JButton();

        jtCuentas.setAutoCreateRowSorter(true);
        jtCuentas.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial Black", 0, 12)));
        jtCuentas.setFont(new java.awt.Font("Arial", 0, 12));
        jtCuentas.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "ID", "Descripcion", "Param1", "Param2", "Param3", "Param4", "Param5", "Param7(decimal)", "Param8(decimal)", "Param9", "Param10", "Fecha", "Param Entero"
            }
        ));
        jtCuentas.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS);
        jScrollPane1.setViewportView(jtCuentas);

        jbModificar.setFont(new java.awt.Font("Arial", 0, 12));
        jbModificar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/fife/plaf/Office2003/replace.gif"))); // NOI18N
        jbModificar.setText("Actualizar");
        jbModificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbModificarActionPerformed(evt);
            }
        });
        jbModificar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jbModificarKeyPressed(evt);
            }
        });

        jbSalir.setFont(new java.awt.Font("Arial", 0, 12));
        jbSalir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/fife/plaf/Office2003/close.gif"))); // NOI18N
        jbSalir.setText("Salir");
        jbSalir.setToolTipText("salir");
        jbSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbSalirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(758, Short.MAX_VALUE)
                .addComponent(jbModificar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbSalir)
                .addContainerGap())
            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 988, Short.MAX_VALUE)
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jbModificar, jbSalir});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 304, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbSalir)
                    .addComponent(jbModificar))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jbModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbModificarActionPerformed
        // TODO add your handling code here:
        
        
        try{
            int indice=jtCuentas.getSelectedRow();
            
            //System.out.println("indice seleciconado "+indice);
            String auxi=jtCuentas.getValueAt(indice,0).toString().trim();
            (new jdActualizaTrataParametro(javax.swing.JOptionPane.getFrameForComponent(this),
                    this.identificador, auxi, fca,this)).setVisible(true);
            
            
        }catch(Exception e){}
    }//GEN-LAST:event_jbModificarActionPerformed

    private void jbModificarKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jbModificarKeyPressed
        // TODO: Agrege su codigo aqui:
    }//GEN-LAST:event_jbModificarKeyPressed

    private void jbSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbSalirActionPerformed
        // TODO add your handling code here:
        cerrar();
       
    }//GEN-LAST:event_jbSalirActionPerformed
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton jbModificar;
    private javax.swing.JButton jbSalir;
    private javax.swing.JTable jtCuentas;
    // End of variables declaration//GEN-END:variables
    
}
